package com.czk.scala.chapter02

/**
 * @Author:ChenZhangKun
 * @Date: 2021/12/6 17:26
 */
object Test_String {
  def main(args: Array[String]): Unit = {
    // 字符串 + 好拼接
    val name: String = "alice"
    val age: Int = 18
    println(name + "------" + age)

    // *用于将一个字符串复制多次拼接，相当于py的字符串乘法
    println(name * 3)

    // printf
    printf("年龄是%d,名字是%s", age, name)
    println()
    // 字符串差值和字符串模板:通过$获取变量值
    println(s"名字是是${name},年龄是${age}")

    val num1: Float = 2.34f
    val num2: Double = 2.56
    // f保留一位小数
    println(f"the num is ${num1}%2.1f")
    // raw输出原格式的值
    println(raw"the num is ${num1}%2.1f")
    // 三引号表示字符串，保持多行字符串的原格式输出,换行这些都保留
    val sql: String =
      s"""
         |select *
         |from
         | student
         | where
         |  name = ${name}
         |  and
         |    age>${age}
         |""".stripMargin
    println(sql)
  }
}
